package com.fenghongzhang.day009;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

import androidx.annotation.Nullable;

class MySqlHelp extends SQLiteOpenHelper {

    private static final String TAG = "MySqlHelp";
    /**
     *
     * @param context 上下文
     * @param name  数据库名字
     * @param factory null  用默认的
     * @param version 1 版本号.
     */
    public MySqlHelp(@Nullable Context context, @Nullable String name, @Nullable SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
    }
    /**
     * 创建数据库.
     * 只会被执行一次.
     * @param db
     */
    @Override
    public void onCreate(SQLiteDatabase db) {
        //通知创建一个表

        db.execSQL("create table student(id integer primary key autoincrement , name varcher(30))");

        //插入数据.
//        db.execSQL("insert ");
    }
    /**
     * 用来更新数据库
     * @param db
     * @param oldVersion
     * @param newVersion
     */
    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        Log.i(TAG, "onUpgrade: ");
    }
}
